Parallaxis Syntax

Parallaxis Language Definition
© Thomas Braunl, Universität Stuttgart, 1989

System          =       SYSTEM  sys_ident ";"
                        { ConstantDecl  |  TypeDecl }
                        HardwareDecl  SoftwareDecl 
                        sys_ident "." .

ConstantDecl    =       CONST  { ident "=" ConstExpr ";" } .
TypeDecl        =       TYPE  { ident "=" type ";" } .

HardwareDecl    =       CONFIGURATION  conf_ident  IntRange  { "," IntRange }  ";" 
                        CONNECTION  [ TransferFunc  { ";"  TransferFunc } ] ";" .
IntRange        =       "["  range  "]" .
range           =       int_ConstExpr  [ ".." int_ConstExpr ] .
TransferFunc    =       out_direction  ":" conf_ident
                        "[" source   { "," source } "]"  ( "->" | "<->" )
                        destination  { "," destination } .
direction       =       ident  [ "(" (integer | const_ident) ")" ] .
source          =       ident  |  integer.
destination     =       [ discriminant ]
                        conf_ident  "["  ExprList  "]"  "."  in_direction.
discriminant    =       "{"  bool_expr  "}".

SoftwareDecl    =       VariableDecl  { ProcedureDecl ";" }
                        block .
VariableDecl    =       [ ControlVarDecl ]  [ LocalVarDecl ] .
ControlVarDecl  =       SCALAR { ident { "," ident } ":" type ";" } .
LocalVarDecl    =       VECTOR { ident { "," ident } ":" type ";" } .
ProcedureDecl   =       PROCEDURE proc_ident [FormalParams] ";"
                        { ConstantDecl  |  TypeDecl }
                        SoftwareDecl proc_ident .
FormalParams    =       "(" [ parameters  { ";" parameters } ] ")"
                        [ ":" ( SCALAR  |  VECTOR )  function_type ] .
parameters      =       SCALAR  [ VAR ]  ident  { "," ident } ":" type  |
                        VECTOR  [ VAR ]  ident  { "," ident  } ":" type .

block           =       BEGIN
                        StatementSeq
                        END .
StatementSeq    =       statement  { ";" statement } .
statement       =       [  assignment  |  ProcedureCall  | 
                          IfSelection  |  CaseSelection  |  WhileLoop  |
                          RepeatLoop   |   LoopStatement |  ForLoop    |
                          WithStatement |  EXIT   |  RETURN  [ expr ]  |
                          ParallelExec  |  Propagate |  Load  |  Store  ] .

ParallelExec    =       PARALLEL  selection
                        StatementSeq
                        ENDPARALLEL .
selection       =       [  "[" entry  "]"  { "," "[" entry  "]" }  ] .
entry           =       range  { "," range }  |  expr  [ ".." expr ]  | "*" .

Propagate       =       PROPAGATE "." out_dirvar  [ "^"  ( integer | ident) ]
                                         [      "." in_dirvar ]
                          "("  vector_designator  [ "," vector_designator ]  ")" .
dirvar          =       ident [ "(" expr ")" ] .
Load            =       LOAD  selection  "(" vector_designator "," scalar_designator
                                [ "," length_designator ] ")" .
Store           =       STORE  selection  "(" vector_designator "," scalar_designator
                                [ "," length_designator ] ")" .
Reduce          =       REDUCE  "."  operator_ident  selection  "(" expr ")" .

assignment      =       designator  ":="  expr .
designator      =       ident { "[" ExprList "]"  |  "." ident } .
ProcedureCall   =       proc_ident [ "("  ExprList  ")" ] .
FunctionCall    =       proc_ident   "("  [ ExprList ]  ")" .
IfSelection     =       IF bool_expr THEN StatementSeq
                        { ELSIF bool_expr THEN StatementSeq }
                        [ ELSE StatementSeq ] END .
CaseSelection   =       CASE  expr  OF  case { "|" case }
                        [ ELSE  StatementSeq ]  END.
case            =       CaseLabels  { "," CaseLabels }  ":"  StatementSeq .
CaseLabels      =       ConstExpr [ ".." ConstExpr ] .
WhileLoop       =       WHILE  bool_expr  DO  StatementSeq  END .
RepeatLoop      =       REPEAT  StatementSeq  UNTIL  bool_expr .
LoopStatement   =       LOOP  StatementSeq  END .
ForLoop         =       FOR ident  ":="  expr  TO expr  [ BY ConstExpr ] 
                        DO StatementSeq END .
WithStatement   =       WITH  designator  DO  StatementSeq  END .

type            =       SimpleType | ArrayType| RecordType | SetType .
SimpleType      =       type_ident |  enumeration  |  subrange .
enumeration     =       "(" const_ident  { "," const_ident } ")" .
subrange        =       "["  ConstExpr  ".."  ConstExpr  "]" .
ArrayType       =       ARRAY SimpleType { "," SimpleType } OF type .
RecordType      =       RECORD FieldListSeq END .
FieldListSeq    =       FieldList  { ";"  FieldList } .
FieldList       =       [ ident { "," ident } ":" type ] .
                        (* variant records not yet supported *)
SetType         =       SET OF SimpleType .

ExprList        =       expr  { "," expr } .
expr            =       SimpleExpr   { relation SimpleExpr } .
relation        =       "=" | "<>" | "#" | "<" | ">" | "<=" | ">=" | IN .
SimpleExpr      =       [ "+" | "-" ]  term  { AddOperator term } .
AddOperator     =       "+" | "-" | OR .
term            =       power  { MulOperator power} .
MulOperator     =       "*" | "/" | DIV | MOD | AND | "&" .
power           =       factor  { "^"  factor } .
factor          =       FunctionCall  |  Reduce  |  string  |  set  |
                        number  |  designator  |  structure  |
                        "(" expr ")"  |  NOT  factor .
string          =       "'" { character } "'"  |  '"' { character } '"' .
set             =       [type_ident] "{" [ element  { "," element } ] "}" .
element         =       ConstExpr [ ".." ConstExpr ] .
structure       =       record_ident  "("  ExprList  ")" .

CExprList       =       [ ConstExpr  { ","  ConstExpr } ] .
ConstExpr       =       SimpleConstExpr  { relation  SimpleConstExpr } .
SimpleConstExpr =       [ "+" | "-" ]  ConstTerm  { AddOperator  ConstTerm } .
ConstTerm       =       ConstPower  { MulOperator  ConstPower } .
ConstPower      =       ConstFactor  { "^"  ConstFactor } .
ConstFactor     =       const_ident  |  number  |  string  |  set  |
                        recarr_ident "(" CExprList ")"  |
                        stdfct_ident "(" CExprList ")"  |
                        "(" ConstExpr ")"  |  NOT  ConstFactor .

number          =       integer  | real .
integer         =       digit {digit} .
real            =       digit {digit} "." {digit} ["E" ["+" | "-"] digit {digit}] .
ident           =       letter { letter | digit } .
character       =       letter | digit | "$" | .. (* any character, e.g. ASCII *) .
digit           =       "0" | . . | "9" .
letter          =       "A" | . . | "Z" | "a" | . . | "z" | "_" .